package com.goudan.demo.schedule;

import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class SampleXxlJob {

    /**
     * 1、简单任务示例（Bean模式）
     */
    @XxlJob("demoJobHandler")
    public void demoJobHandler() throws Exception {
        XxlJobHelper.log("XXL-JOB,苟蛋的调度： Hello World.");
        String param = XxlJobHelper.getJobParam();
        System.out.println("我的调度hello world!!!!!!!开始了，开心..........参数：" + param);
        for (int i = 0; i < 5; i++) {
            XxlJobHelper.log("beat at:" + i);
            System.out.println("我的调度hello world!!!!!!!");
            TimeUnit.SECONDS.sleep(2);
        }
        // default success
    }
}
